﻿

var oTab = document.getElementById('LogonBak'), //$('#LogonBak'),
        oTab1 = document.getElementById('normalLogin'), //$('#normalLogin'),
        oTab2 = document.getElementById('mailLogin');  //$('#mailLogin');

function fBodyVericalAlign() 
{
    var nBodyHeight = 572;
    var nClientHeight = document.documentElement.clientHeight;
    if (nClientHeight >= nBodyHeight + 2) {
        var nDis = (nClientHeight - nBodyHeight) / 2;
        document.body.style.paddingTop = nDis + 'px';
    }
    else {
        document.body.style.paddingTop = '0px';
    }
}
var tab1Cls = 'lgonDiv tab-1', tab2Cls = 'lgonDiv tab-2';
var ntabOn = 1, sTempName, sTempPwd, sTempMob, sTempMobPwd;
function fSwitchTab() {
    if (ntabOn == 1) {
        oTab.className = tab2Cls;
        ntabOn = 2;
        fEventUnlisten(oTab2, 'mouseover', fSwitchTabTimeOut);
        fEventUnlisten(oTab2, 'mouseout', fSetSwitchTabTimeOut);
        fEventListen(oTab1, 'mouseover', fSwitchTabTimeOut);
        fEventListen(oTab1, 'mouseout', fSetSwitchTabTimeOut);
    }
    else {
        oTab.className = tab1Cls;
        ntabOn = 1;
        fEventUnlisten(oTab1, 'mouseover', fSwitchTabTimeOut);
        fEventUnlisten(oTab1, 'mouseout', fSetSwitchTabTimeOut);
        fEventListen(oTab2, 'mouseover', fSwitchTabTimeOut);
        fEventListen(oTab2, 'mouseout', fSetSwitchTabTimeOut);
    }
}

function fEventListen(oElement, sName, fObSever, bUseCapture) {

    bUseCapture = !!bUseCapture;
    if (oElement.addEventListener) {
        oElement.addEventListener(sName, fObSever, bUseCapture);
    } else if (oElement.attachEvent) {
        oElement.attachEvent('on' + sName, fObSever);
    }
}

function fEventUnlisten(oElement, sName, fObserver, bUseCapture) {
    bUseCapture = !!bUseCapture;
    if (oElement.removeEventListener) {
        oElement.removeEventListener(sName, fObserver, bUseCapture);
    } else if (oElement.detachEvent) {
        oElement.detachEvent("on"+sName, fObserver, bUseCapture);
    }
}
var bswitchTabTimeOut = false;
function fSwitchTabTimeOut() {
    setTimeout(function () {
            if (!bswitchTabTimeOut) {
                fSwitchTab();
            }
            else {
                bswitchTabTimeOut = false;
            }
    }, 3000);
}

function fSetSwitchTabTimeOut() {
    bswitchTabTimeOut = true;
}
